<?php
/**
 * Created by PhpStorm.
 * User: lili
 * Date: 2018/12/31
 * Time: 0:15
 */

namespace system\library;


class Session
{
    
    private static $instance;
    
    private function __construct(){
        $this->session();
    }

    /**
     * @return mixed
     */
    public static function getInstance()
    {   
        if (empty(self::$instance)){
            self::$instance = new self();
        }
        return self::$instance;
    }
    
    
    public  function session()
    {
        session_start();
    }

    public  function set($name, $value)
    {
        $_SESSION[$name] = $value;
    }

    public  function get($name)
    {
        if(isset($_SESSION[$name]))
            return $_SESSION[$name];
        else
            return false;
    }

    public  function del($name)
    {
        unset($_SESSION[$name]);
    }

    public  function destroy()
    {
        $_SESSION = array();
        session_destroy();
    }
    
    public function __destruct()
    {
        $this->destroy();
        // TODO: Implement __destruct() method.
    }


}